﻿@{
    ViewBag.Title = "Form";
    Layout = "~/Views/Shared/_Form.cshtml";
}


<form id="form1">
    <div role="tabpanel" class="tab-pane fade in" style="padding-top: 20px; margin-right: 30px;">
        <div id="orgList"></div>
    </div>
</form>

<div style="position: fixed; bottom: 10px; right: 10px;">
    <a class="btn btn-primary" onclick="btn_authall()">授权全部</a>
    &nbsp;&nbsp;
    <a class="btn btn-danger" onclick="btn_authcancelall()">撤销全部</a>
</div>

<script>
    var keyValue = $.request("keyValue");
    $(function () {
        $('#myTab a:first').tab('show');
        $("#orgList").treeview({
            height: 400,
            slimscroll: false,
            showcheck: true,
            url: "/Organize/GetAuthOrganizeList",
            param: { keyValue: keyValue }
        });
    });
    function submitForm() {
        var postData = {};
        postData["orgList"] = String($("#orgList").getCheckedNodes());
        $.submitForm({
            url: "/Module/UpdateAuthOrganizeList?keyValue=" + keyValue,
            param: postData,
            success: function () {
                //$.currentWindow().$("#gridList").trigger("reloadGrid");
            }
        })
    }
    function btn_authall() {
        $.modalConfirm("授权给全部机构", function (flag) {
            if (flag) {
                var postData = {};
                $.submitForm({
                    url: "/Module/AuthAllOrganize?keyValue=" + keyValue,
                    param: postData,
                    success: function () {
                        //$.currentWindow().$("#gridList").trigger("reloadGrid");
                    }
                });
            }
        });
    }
    function btn_authcancelall() {
        $.modalConfirm("撤销全部授权", function (flag) {
            if (flag) {
                var postData = {};
                $.submitForm({
                    url: "/Module/AuthCancelAllOrganize?keyValue=" + keyValue,
                    param: postData,
                    success: function () {
                        //$.currentWindow().$("#gridList").trigger("reloadGrid");
                    }
                });
            }
        });
    }
</script>